//
// Created by linxi on 2021/1/22.
//

#ifndef UNTITLED1_MYMQTT_H
#define UNTITLED1_MYMQTT_H

#include <PubSubClient.h>
#include "wifi.h"

// topic
#define TEMPERATURE "temperature"
#define LED_CONTROL "LED_Control"
#define LED_Status "LED_Status"

// MQTT
#define mqttServer "116.62.131.51"
#define mqttPort 6050


//#define mqttServer "test.ranye-iot.net"
//#define mqttPort 1883


#define mqtt_username "linxi"
#define mqtt_password "080899"

// global common topic prefix
#define Device_Name (String)"NodeMCU-" + WiFi.macAddress()
#define Pub_pefix "/Pub/"
#define Sub_pefix "/Sub/"

// 遗嘱设置
#define willMsg "-0" // 遗嘱消息内容
#define willQoS 0                  // 遗嘱QoS
#define willRetain true           // 遗嘱保留



void connectMQTTServer();
void receiveCallback(char *topic, byte *payload, unsigned int length);
void pubMQTTmsg(const String& topic, const char* publishMsg, bool status);
void subscribeTopic(const String& topic);
void publishOnlineStatus();
#endif //UNTITLED1_MYMQTT_H
